{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=654
  Verdict: Accepted
}
const button:array['A'..'Z'] of byte = (1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,6,7,7,7,8,8,8,8);
const press:array['A'..'Z'] of byte = (1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,4,1,2,3,1,2,3,4);
Const MaxDig=100; Osn=10;
Type Tlong = Array[0..MaxDig] Of Integer;
var i,n,cur,t,j,k,g:longint; p:array[1..321] of byte; s:string; a:array[-4..81,-4..321] of tlong; cl:tlong;
 
Procedure convert(s:string; Var A:Tlong);
Var ch:char; i,j:longint;
Begin
FillChar(A, SizeOf(A), 0) ;
for j:=1 to length(s) Do Begin
      For i:=A[0] DownTo 1 Do Begin
          A[i+1]:=A[i+1]+(LongInt(A[i])*10) Div Osn;
          A[i]:=(LongInt(A[i])*10) Mod Osn
      End;
      A[1]:=A[1]+Ord(s[j])-48;
      If A[A[0]+1]>0 Then Inc(A[0]);
End;
End;
 
Procedure WriteLong(Const A:Tlong);
Var ls,s:string; i:longint;
Begin
Str(Osn Div 10,ls);
Write(A[A[0]]);
For i := A[0]-1 DownTo 1 Do Begin
    Str(A[i],s);
    While Length(s) < Length(ls) Do s := '0' + s;
    write(s)
End;
WriteLn
End;
 
 
Procedure SumLongTwo(A,B:Tlong; Var C:Tlong);
Var i,k:longint;
Begin
FillChar(C, SizeOf (C), 0) ;
If A[0]>B[0] Then k:=A[0] Else k:=B[0];
For i:=1 To k Do Begin
    C[i+1]:=(C[i]+A[i]+B[i]) Div Osn;
    C[i]:=(C[i]+A[i]+B[i]) Mod Osn
End;
If C[k+1]=0 Then C[0]:=k Else C[0]:=k+1
End;
 
begin
assign(input,'input.txt');
assign(output,'output.txt');
reset(input);
rewrite(output);
fillchar(p,sizeof(p),0);
fillchar(a,sizeof(a),0);
readln(n);
readln(s);
cur:=0;
for i:=1 to length(s) do begin
    for j:=1 to press[s[i]] do begin
        inc(cur);
        p[cur]:=button[s[i]];
    end;
end;
t:=0;
convert('1',a[0][0]);
for i:=1 to n do
    for j:=1 to cur do convert('0',a[i][j]);
for i:=1 to n do begin
    for j:=1 to cur do begin
        if p[j]=p[j-1] then inc(t) else t:=1;
        if (t>=4) and ((p[j]=6) or (p[j]=8)) then begin
           sumlongtwo(a[i-1][j-1],a[i-1][j-2],a[i][j]);
           cl:=a[i][j];
           sumlongtwo(cl,a[i-1][j-3],a[i][j]);
           cl:=a[i][j];
           sumlongtwo(cl,a[i-1][j-4],a[i][j]);
        end else
        if t>=3 then begin
           sumlongtwo(a[i-1][j-1],a[i-1][j-2],a[i][j]);
           cl:=a[i][j];
           sumlongtwo(cl,a[i-1][j-3],a[i][j]);
        end else
        if t>=2 then begin
           sumlongtwo(a[i-1][j-1],a[i-1][j-2],a[i][j]);
        end else
        if t=1 then a[i][j]:=a[i-1][j-1];
    end;
end;
writelong(a[n][cur]);
end.